package acwing.差分;

import java.util.Arrays;
import java.util.Scanner;

/**
 * 干草堆
 *
 * @author yang
 * @date 2022/1/5
 */
public class 干草堆 {


    static int N = 1000010;
    static int n,m;
    static int[] arr = new int[N];
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        m = sc.nextInt();
        while (m-- > 0) {
            int l, r;
            l = sc.nextInt();
            r = sc.nextInt();
            arr[l]++;
            arr[r + 1]--;
        }
        for (int i = 1; i <= n; i++) arr[i] += arr[i - 1];
        Arrays.sort(arr,0, n + 1);
        System.out.println(arr[n/2 + 1]);
    }
}
